#include<iostream>
#include<string>
 
 
class Entity
{
public:
	void Print() const { std::cout << "Hello!" << std::endl; }
 
};
 
class ScopedPtr
{
private:
	Entity* m_Obj;
 
public:
	ScopedPtr(Entity* entity)
		: m_Obj(entity)
	{
 
	}
 
	~ScopedPtr()
	{
		delete m_Obj;
	}
   
    Entity* operator->() //重载->运算符
    {
        return m_Obj;
    }

    const Entity* operator->() const
    {
        return m_Obj;
    }
};
 
 //-> 获取内存偏移量
struct Vector3
{
    float x,y,z;
};
 
int main()
{
    const ScopedPtr entity = new Entity(); //调用const Entity* operator->() const 版本
 
	entity->Print();
 
    int offset = (int)&((Vector3*)nullptr)->y;
    std::cout << offset << std::endl;

	std::cin.get();
 
}